﻿using UnityEngine;

public class Movement : MonoBehaviour
{
    public float speed = 5;
    public float angularSpeed = 30;
    public float roleID = 1;                    //增加一个玩家的编号，通过编号区分不同的控制
    private Rigidbody rigidbody;
    // Start is called before the first frame update
    void Start()
    {
        rigidbody = this.GetComponent<Rigidbody>();
    }

    private void FixedUpdate()
    {
        float v = Input.GetAxis("VerticalPlayer" + roleID);
        rigidbody.velocity = transform.forward * v * speed;
        float h = Input.GetAxis("HorizontalPlayer" + roleID);
        rigidbody.angularVelocity = transform.up * h * angularSpeed;
    }
}
